const { app, BrowserWindow } = require('electron');

const path = require('path');

let win;

global.sharedObj = {myvar: "hellofrommainjs"};

function create_win()
{
    win = new BrowserWindow({
        width: 1330,
        height: 960,
        // center: true,
        // resizable: false,
        // movable: false,
        // minimizable: true,
        // maximizable: true,
        // fullscreen: true,

        // protocol: 'file:',
        webPreferences: {
            preload: path.join(__dirname, 'preload.js'),
            webviewTag: true, // webview tag is disabled in Electron >= 5.
            nativeWindowOpen: true,
            backgroundColor: '#eee',
            nodeIntegration: true, 
        },
    });

    win.loadFile('index.html');
    // mainWindow.loadURL(`file://${__dirname}/index.html`);
    // mainWindow.loadURL('file://' + __dirname + '/index.html');
    win.webContents.openDevTools();

    win.on('closed', function() {
        win = null;
    });
}


app.on('ready', create_win);
app.on('window-all-closed', function() {
    // for macOS,like Cmd+Q
    if (process.platform == 'darwin') app.quit();
});
app.on('activate', function() {
    // for macOS
    if (win == null) create_win();
});